<!-- 左边图标跳转 页面 -->
<template>
	<view class="v-index-left">
        

		<block v-if="partnerSetObj.apply_desc">
			<uv-parse :content="partnerSetObj.apply_desc" :selectable="true"></uv-parse>

			<view class="commission flex-start-center">
				<image class="avatar" :src='user.avatar?user.avatar:avatarUrl' mode=""></image>
				<view class="flex-columns">
					<view class="font-size_32rpx " style="color: #fff;">
						{{user.nickname?user.nickname:'xxxxxx'}}
					</view>
					<view class="margin-top_16rpx">
						<text style="color: #A6A6A6; ">我的佣金</text> <text
							style="color: #FFE1B3; ">￥{{user.brokerage?user.brokerage:'xxxxxx'}}</text>
					</view>
				</view>
			</view>

		</block>
		<!-- <block v-else>
			<view class="team flex-column ">
				<image src="/static/nodata.png"></image>
				<text class="text">空空如也 ~</text>
			</view>
		</block> -->
		<button v-if="partnerSetObj.is_open&&user.is_partner==0" class="v-call"
			@click="call()">{{partnerSetObj.is_money?'￥'+partnerSetObj.money:'免费申请'}}成为超级合伙人</button>
	</view>
</template>

<script>
	import antiThrottling from '@/utils/antiThrottling.js';
	export default {
		data() {
			return {

				leftText: uni.getStorageSync('system').left_text,
				user: '',
				heightSystemss: 0,
				customBar: 0,
				scrollTop: 0, //滚动距离
				hiddenModel: true, //显示影藏
				opacityStyle: 0,
				partnerSetObj: {},
				itemAll: '',
				avatarUrl: '/static/avatar.png',
			};
		},
		onLoad() {
			this.createdgetSystemInfo();
			this.partnerSetFn()
		},
		onShow() {
			this.partnerSetFn()
			this.userInfos()
			antiThrottling.releaseKey('submit');
		},

		onPageScroll(ev) {


			if (ev.scrollTop > 10) {
				let opacity = ev.scrollTop / 140

				// this.opacityStyle = opacity > 1 ? 1 : opacity
				this.opacityStyle = 1
				this.hiddenModel = false
				// this.createdgetSystemInfo();

			} else {
				this.hiddenModel = true
			}
		},
		methods: {
			async partnerSetFn() {
				const result = await this.$http.post({
					url: this.$api.partnerSet,
					data: {

					}
				});
				if (result.errno == 0) {

					this.partnerSetObj = result.data;
				}
			},
			toRe() {
				this.$sun.navBack();
			},
			createdgetSystemInfo() {
				uni.getSystemInfo({
					success: e => {
						// 文章网址：https://blog.csdn.net/weixin_44510655/article/details/127131947
						this.heightSystemss = e.statusBarHeight;
						const custom = wx.getMenuButtonBoundingClientRect();
						this.customBar = ((custom.top - e.statusBarHeight) * 2 + custom.height) / 4;
					}
				});
			},
			// 拨打电话
			call() {
				antiThrottling.uniDoFunc({
					// 键名
					key: 'submit',
					success: async () => {
						//锁定
						antiThrottling.lockKey('submit');

						console.log('111')

						const result = await this.$http.get({
							url: this.$api.partnerApply,
							data: {

								uid: uni.getStorageSync('uid'),


							}
						});
						if (result.errno == 0) {

							this.itemAll = result.data;


							antiThrottling.releaseKey('submit');
							if (this.partnerSetObj.money != '0.00') {
								this.applyOrder()
							} else {
								this.partnerSetFn()
								this.$sun.toast(result.message, 'none')
							}



						}
					}
				});

			},
			applyOrder(number) {
				this.pays(this.itemAll);
			},
			// 支付
			async pays(item) {
				const result = await this.$http.get({
					url: this.$api.wxPay,
					data: {

						// 支付金额
						price: this.partnerSetObj.money,
						// 订单编号
						log_no: item,
						// opid
						openid: wx.getStorageSync('user').openid,

						name: '申请合伙人'
					}
				});
				if (result.errno == 0) {
					this.$sun.title('支付');
					const pay = result.data;
					this.$sun.wePay(
						pay,
						async success => {
								antiThrottling.releaseKey('submit');
								// false 普通商品 true团购商品
								// this.$sun.navRe('/pages/orderMessage/orderDetail/orderDetail');
								this.$sun.toast('支付成功');
								this.userInfos()
								this.partnerSetFn()
							},
							async cancel => {
								this.$sun.toast('取消了支付');
								antiThrottling.releaseKey('submit');

							}
					);
				} else {
					this.$sun.toast(result.message);
					antiThrottling.releaseKey('submit');
				}
			},
			async userInfos() {
				const result = await this.$http.get({
					url: this.$api.userInfo,
					data: {
						// 用户id
						uid: uni.getStorageSync('uid'),
						// 上级id
						// pid: uni.getStorageSync('pid') ? uni.getStorageSync('pid') : ''
						// pid: ''
					}
				});
				if (result.errno == 0) {
					this.user = result.data;
					uni.setStorageSync('user', this.user);

				}
			},
			// 开发者报名信息 表单填写
			async leftTables() {
				const result = await this.$http.post({
					url: this.$api.leftTable,
					data: {
						//  姓名
						name: uni.getStorageSync('user').nickname,
						// 电话号码
						mobile: uni.getStorageSync('mobile'),
						// 用户id
						uid: uni.getStorageSync('uid')
					}
				});
				if (result.code == 0) {
					this.tableList = result.data;
				}
			}
		}
	};
</script>

<style lang="scss">
	/deep/ button::after {
		border: none;
		margin: 0rpx;
		padding: 0rpx;
	}

	.v-index-left {
		position: relative;

		.commission {
			position: absolute;
			top: 20%;
			z-index: 999;
			left: 42%;
			transform: translate(-50%, -50%);

			.avatar {
				width: 104rpx;
				height: 106rpx;
				margin-right: 20rpx;
				border-radius: 50%;
			}
		}

		#barTitle {
			position: fixed;
			width: 750rpx;
			top: 0;
			left: 0;
			background: #fff;
			color: #000000;
			text-align: center;
			font-weight: bold;
			z-index: 9999
		}

		#barTitle>text {
			position: absolute;
			left: 0;
			right: 0;
			bottom: 20rpx
		}

		.v-return {
			display: flex;
			align-items: center;
			// background-color: #fff;
			// position: fixed;
			width: 100%;
			// padding:0 30rpx;
			z-index: 999;

			image {
				width: 36rpx;
				height: 36rpx;
				margin-right: 10rpx;
			}

			text {
				font-size: 32rpx;
			}
		}

		.alsdjaa {
			margin: 30rpx;
		}

		.team {
			width: 750rpx;
			padding: 100rpx 0rpx;
			background-color: #ffffff;
			z-index: 99;

			image {
				width: 280rpx;
				height: 280rpx;
			}

			text {
				margin-top: 20rpx;
				font-size: 24rpx;
				color: gray;
			}
		}

		.v-call {
			font-size: 29rpx;
			font-weight: 700;
			border-radius: 98rpx;
			padding: 10rpx 40rpx;
			background: linear-gradient(90.00deg, rgb(253, 226, 170), rgb(249, 189, 118) 55.978%, rgb(248, 194, 125) 100%);
			color: #442D25;
			// color: #ffffff;
			width: 70%;
			position: fixed;
			bottom: 40rpx;
			left: 15%;
			border: none;

			z-index: 999;
			/* 		background-image: linear-gradient(to right , #FEFEE0,#FFF1AE,#FFAC53);
		// background-image: linear-gradient(to right bottom , #bae1ff,#499DFD,#0153FF);
		color: #fff;
		width: 90%;margin: 5%; */
		}
	}
</style>